//
//  CXHToBidRewardVideoAdapter.m
//  CXHAdSDK-ToBid
//
//  Created by 陈坤 on 2025/4/4.
//

#import "CXHToBidRewardVideoAdapter.h"
#import <WindFoundation/WindFoundation.h>
#import "CXHToBidRewardVideoAd.h"

@interface CXHToBidRewardVideoAdapter ()
@property (nonatomic, weak) id<AWMCustomRewardedVideoAdapterBridge> bridge;
@property (nonatomic, strong) id<CXHToBidAdProtocol> ad;

@end

@implementation CXHToBidRewardVideoAdapter

- (instancetype)initWithBridge:(id<AWMCustomRewardedVideoAdapterBridge>)bridge {
    self = [super init];
    if (self) {
        _bridge = bridge;
    }
    return self;
}
- (BOOL)mediatedAdStatus {
    return [self.ad mediatedAdStatus];
}
- (void)loadAdWithPlacementId:(NSString *)placementId parameter:(AWMParameter *)parameter {
    int templateType = [[parameter.customInfo objectForKey:@"templateType"] intValue];
    self.ad = [[CXHToBidRewardVideoAd alloc] initWithBridge:self.bridge adapter:self];
    [self.ad loadAdWithPlacementId:placementId parameter:parameter];
}
- (BOOL)showAdFromRootViewController:(UIViewController *)viewController parameter:(AWMParameter *)parameter {
    return [self.ad showAdFromRootViewController:viewController parameter:parameter];
}
- (void)didReceiveBidResult:(AWMMediaBidResult *)result {
    [self.ad didReceiveBidResult:result];
}
- (void)destory {
    self.ad = nil;
}
- (void)dealloc {
    WindmillLogDebug(@"[cxh]", @"%s", __func__);
}

@end
